package cn.blnp.net.flowable.event.bound.error;

import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.BpmnError;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

/**
 * <h3></h3>
 *
 * @author <a href="mailto:blnp.yibin@qq.com">lyb</a>
 * @version 1.0
 * @since 2025/5/8 17:56
 */
@Slf4j
@Component
public class AutomaticReviewService implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        String healthCodeStatus = (String) execution.getVariable("healthCodeStatus");
        if (!"green".equals(healthCodeStatus)) {
            String errorCode = "healthCodeNotGreen";
            log.error("健康码异常，抛出BPMN错误，errorCode为：{}", errorCode);
            throw new BpmnError(errorCode);
        }
    }
}
